/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.wb.picmover.server;

import cn.ac.iie.di.wb.picmover.handler.PicHandler;
import cn.ac.iie.di.wb.picmover.handler.RocketMqClient;
import cn.ac.iie.di.wb.picmover.kill.KillHandler;
import cn.ac.iie.di.wb.picmover.send.PicSendHandler;
import cn.ac.iie.di.wb.picmover.util.GlobalParameters;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
 *
 * @author Administrator
 */
public class GWXMoverStartUp {

    static Logger logger = null;

    static {
        PropertyConfigurator.configure(ClassLoader.getSystemClassLoader().getResource("log4j.properties"));
        logger = Logger.getLogger(GWXMoverStartUp.class.getName());
    }

    public static void main(String[] args) {

        KillHandler killhandle = new KillHandler();
        killhandle.registerSignal("TERM");

        //初始化参数
        GlobalParameters.init();
        //发送消息队列
//        sendMQ();
        //处理消息
        handler(killhandle);
        
    }

    public static void handler(KillHandler killhandle) {
        //接收消息
        RocketMqClient mqClient = new RocketMqClient(GlobalParameters.pic_from_topic + ":" + GlobalParameters.pic_from_group, killhandle);
        Thread recvMessageThread = new Thread(mqClient);
        recvMessageThread.setName("###ReceiveMessage");
        recvMessageThread.start();

        //处理消息
        Thread picThread = new Thread(new PicHandler());
        picThread.setName("###PicHandler");
        picThread.start();
    }

    public static void sendMQ() {
        Thread picSendThread = new Thread(new PicSendHandler());
        picSendThread.setName("@@PicSend@@");
        picSendThread.start();
    }

}
